$def with(work, tags=[])

$def render_subjects(label, subjects, prefix=""):
  $if subjects:
    <div class="section link-box">
      <h6>$label</h6>
      <span>
        $for subject in subjects:
          <a href="/subjects/$prefix$utf8(subject.lower().replace(' ', '_').replace(',',''))">$subject</a>$cond(not loop.last,",","")
      </span>
    </div>

$if work:
  $for tag in tags:
    $if tag=="Subjects":
      $:render_subjects(_("Subjects"), work.get_subjects())
    $elif tag=="People":
      $:render_subjects(_("People"), work.subject_people, prefix="person:")
    $elif tag=="Places":
      $:render_subjects(_("Places"), work.subject_places, prefix="place:")
    $elif tag=="Times":
      $:render_subjects(_("Times"), work.subject_times, prefix="time:")
